package com.flower.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 *@ClassName FlowerController
 *@Description TODO
 *@Author 吃麻椒的花酱
 *@Date 2021/8/20 13:31
 *@Version 1.0
 */
@RestController
public class FlowerController {
    @SentinelResource(value="getTest",blockHandler="blockHandlerException",fallback="fallbackHandlerException")
    @RequestMapping("/getTest")
    public String test(){
        System.out.println(1/0);
        return "sentinel测试测试测试";
    }

    public String blockHandlerException(BlockException blockException){
        return "sentinel测试异常";
    }

    public String fallbackHandlerException(Throwable throwable){
        return "发生了异常";
    }
}
